package com.gadgets.busi.bm01.service;

import com.gadgets.busi.bm01.dto.TxtCopyQueryDTO;
import com.gadgets.busi.bm01.pojo.CopyTxtTask;
import com.gadgets.busi.bm01.repository.ICopyTxtTaskRepository;
import com.gadgets.framework.common.dto.Pagination;
import com.gadgets.framework.common.exception.GadgetsServiceException;
import com.gadgets.framework.common.util.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2022-03-08
 */
@Service
@Transactional(transactionManager = "gadgetsDbTransactionManage", rollbackFor = Throwable.class)
public class TxtCopyQueryServiceImpl implements ITxtCopyQueryService{

    @Autowired
    private ICopyTxtTaskRepository copyTxtTaskRepository;

    /**
     * 分页条件查询文件拷贝任务
     *
     * @param queryDTO   查询条件
     * @param pagination 分页条件
     * @return 查询结果
     * @throws GadgetsServiceException 异常信息
     */
    @Transactional(transactionManager = "gadgetsDbTransactionManage", rollbackFor = Throwable.class)
    @Override
    public List<CopyTxtTask> selectCopyTaskInfo(TxtCopyQueryDTO queryDTO, Pagination pagination) throws GadgetsServiceException {
        PaginationUtil.bulidPaginationInfo(pagination);
        List<CopyTxtTask> copyTxtTasks = copyTxtTaskRepository.selectCopyTxtTask(queryDTO);
        PaginationUtil.getPaginationResultInfo(copyTxtTasks, pagination);
        return copyTxtTasks;
    }

}
